from pydantic import BaseModel, EmailStr
from typing import Optional
from datetime import datetime

class UserBase(BaseModel):
    username: str
    email: EmailStr

class UserCreate(UserBase):
    password: str

class User(UserBase):
    id: int
    is_active: bool
    created_at: datetime
    last_login: Optional[datetime] = None

    class Config:
        from_attributes = True

# 新增：用户配置schema
class UserConfigBase(BaseModel):
    config_key: str
    config_content: str

class UserConfigCreate(UserConfigBase):
    pass

class UserConfigOut(UserConfigBase):
    id: int
    updated_at: datetime

    class Config:
        orm_mode = True 